<template>
	<gui-page class="container" :customFooter="true" 
	:refresh="true" 
	@reload="reloadData" 
	@scroll="bodyScroll"
	:apiLoadingStatus="apiLoadingStatus"
	ref="guipage"
	>
		<!-- 请开始您的开发 ~ -->
		<template v-slot:gBody>
			<view class="gui-padding">
				<view class="text">
					智能门牌
				</view>
				<view class="meet" @click="toMeet">
					<image class="meet_icon" src="../../static/img/qs.png" />
					<text class="meet_text">会议室预约</text>
				</view>

				<view class="day-text" v-for="item in list">
					<view style="margin-top: 10px;">
						<text style="color: rgb(109,124,149)">日报时间</text>
						<text style="color: rgb(109,124,149);float: right;">{{item.createDate}}</text>
					</view>
					<view style="background-color: #ebeef5;height: 1px;width: 100%;margin: 20px 0;"></view>
					<view>
						<view style="color: rgb(12,37,78);font-weight: bold;">
							今日工作
						</view>
						<view style="color: rgb(61,81,113);">
							<pre>{{item.content}}</pre>
							
						</view>
				
					</view>
					<view style="background-color: #ebeef5;height: 1px;width: 100%;margin: 20px 0;"></view>
					<view style="width: 90px;margin-top: 10px;position: relative;left: 75%;" v-if="item.createDate.split(' ')[0]==this.toDayTime">
						<button @click="toUpdate(item.id)" type="default" class="gui-button gui-bg-blue gui-noborder">
							<text class="gui-color-white gui-button-text">修改</text>
						</button>
					</view>
				
				</view>
				


				

			</view>


		</template>
		<template v-slot:gFooter >
			<view class="gui-padding" style="background-color: white;">
				<view >
					<button @click="addDaily" type="default" class="gui-button gui-bg-blue gui-noborder">
						<text class="gui-color-white gui-button-text">新增日报</text>
					</button>
				</view>
			</view>
			
		</template>
	</gui-page>
</template>

<script>
	import graceChecker from "@/Grace6/js/checker.js";
	import graceJS from "@/Grace6/js/grace.js";
	import BASE_URL from '@/config/api.js'
	export default {
		data() {
			
			return {
				list:[],
				apiLoadingStatus: false,
				toDayTime:''
			}
		},
		onLoad: function() {
			// 获取页面高度
			var system = uni.getSystemInfoSync();
			this.getList();
			const now = new Date();
			const year = now.getFullYear(); // 年
			const month = now.getMonth() + 1; // 月
			const date = now.getDate(); // 日
			this.toDayTime=year+'-'+month+'-'+date
			
			
		},
		methods: {
			toUpdate(id){
				graceJS.navigate('/pages/daily/daily?id='+id, 'navigateTo');
			},
			bodyScroll(e){
				console.log(e.detail.scrollTop);
			},
			reloadData(){
				this.getList();
			},
			getList(){
				this.apiLoadingStatus = true;
				var token = graceJS.getStorage('token');
				var userId = graceJS.getStorage('userId');
				graceJS.get(
					BASE_URL + '/display/daily/daily/listByUser', 
					{},
					{Token:token},
					(res) => {
						
						
						this.list=res.page.list
						this.apiLoadingStatus = false;
						this.$refs.guipage.endReload();
						
					},
					(e) => {
						console.log(e);
					}
				);
				
			},
			addDaily(){
				graceJS.navigate('/pages/daily/daily', 'navigateTo');
			},
			toMeet(){
				graceJS.navigate('/pages/meet/meet', 'navigateTo');
			}
		}
	}
</script>

<style scoped>
	.container {
		background-image: url(../../static/img/bj.png);
		background-size: cover;
		background-repeat: no-repeat;
	}

	.text {
		text-align: center;
		font-size: 20px;
		font-weight: 500;
		color: rgb(12, 37, 78);
		margin-top: 100rpx;
	}

	.meet {
		background-color: white;
		height: 120rpx;
		margin-top: 40rpx;
		border-radius: 0.5rem;
		text-align: center;
		padding-top: 50rpx;
	}

	.meet_icon {
		width: 80rpx;
		height: 80rpx;
		vertical-align: middle;
	}

	.meet_text {
		color: rgb(12, 37, 78);
		font-size: 20px;
	}

	.day-text {
		padding: 20rpx;
		margin-top: 20rpx;
		border-radius: 0.5rem;
		/* height: 400rpx; */
		background-color: white
	}
</style>